
const menuAs = document.querySelectorAll('.menu .section a')
const modals = document.querySelectorAll('.menu .modal')

for (let i = 0; i < menuAs.length; i++) {
    menuAs[i].onmouseenter = function () {
        // console.log(menuAs[i])
        menuAs[i].className = 'orange'
        modals[i].style.display = 'block'
    }

    menuAs[i].onmouseleave = function () {
        modals[i].style.display = 'none'
        menuAs[i].className = ''
    }

    modals[i].onmouseenter = function () {
        modals[i].style.display = 'block'
        menuAs[i].className = 'orange'
    }

    modals[i].onmouseleave = function () {
        modals[i].style.display = 'none'
        menuAs[i].className = ''
    }
}








const mainAs = document.querySelectorAll('.img a')
const banner = document.querySelector('.menu')
const nextNtn = document.querySelector('.menu .left-btn')
const prevBtn = document.querySelector('.menu .right-btn')

let initNum = 0
let bannerTimer = setInterval(function () {
    for (let i = 0; i < mainAs.length; i++) {
        mainAs[initNum].classList.remove('show')
    }

    initNum += 1
    if (initNum >= mainAs.length) {
        initNum = 0
    }
    console.log(initNum)
    mainAs[initNum].classList.add('show')
    // console.log(initNum)
}, 5000)

banner.onmouseenter = function () {
    clearInterval(bannerTimer)
}

banner.onmouseleave = function () {
    bannerTimer = setInterval(function () {
        for (let i = 0; i < mainAs.length; i++) {
            mainAs[initNum].classList.remove('show')
        }

        initNum += 1
        if (initNum >= mainAs.length) {
            initNum = 0
        }
        console.log(initNum)
        mainAs[initNum].classList.add('show')
        // console.log(initNum)
    }, 5000)
}

nextNtn.onclick = function () {
    for (let i = 0; i < mainAs.length; i++) {
        mainAs[initNum].classList.remove('show')
    }

    initNum += 1
    if (initNum > mainAs.length - 1) {
        initNum = 0
    }
    console.log(initNum)
    mainAs[initNum].classList.add('show')
}

prevBtn.onclick = function () {
    for (let i = 0; i < mainAs.length; i++) {
        mainAs[initNum].classList.remove('show')
    }

    initNum -= 1
    if (initNum < 0) {
        initNum = mainAs.length - 1
    }
    console.log(initNum)
    mainAs[initNum].classList.add('show')
}
